package main

import "fmt"

func main() {
	var countryCapitalMap map[string]string /*创建集合 */
	countryCapitalMap = make(map[string]string)

	countryCapitalMap["010"] = "北京"
	countryCapitalMap["020"] = "天津"
	countryCapitalMap["030"] = "上海"
	countryCapitalMap["040"] = "广州"
	fmt.Println(countryCapitalMap)

	countryCapitalMap["040"] = "深圳"
	fmt.Println(countryCapitalMap)

	// 遍历
	for key, value := range countryCapitalMap {
		fmt.Printf("key:%s ==== value:%s \n", key, value)
	}

	for s := range countryCapitalMap {
		fmt.Println(s) // key
	}
	value, ok := countryCapitalMap["010"]
	if ok {
		fmt.Println("key 存在", value)
	} else {
		fmt.Println("key 不存在")
	}

	delete(countryCapitalMap, "040")
	for key, value := range countryCapitalMap {
		fmt.Printf("key:%s ==== value:%s \n", key, value)
	}

}
